const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')
const baseConfig = require('./webpack.common.js')

const {
  CleanWebpackPlugin
} = require('clean-webpack-plugin')

module.exports = merge(baseConfig, {
  mode: 'development',
  devtool: "cheap-module-eval-source-map",
  devServer: {
    hot: true,
    open: true,
    // hotOnly:true
  },
  module: {
    rules: [{
      test: /\.js$/,
      use: [{
        loader: 'eslint-loader',
        options: { // 这里的配置项参数将会被传递到 eslint 的 CLIEngine 
          formatter: require('eslint-friendly-formatter') // 指定错误报告的格式规范
        }
      }],
      enforce: "pre", // 编译前检查
      exclude: /node_modules/, // 不检测的文件
      include: [path.resolve(__dirname, 'src')], // 指定检查的目录
    }, ]
  },
  plugins: [
    // new CleanWebpackPlugin(),
    // 热更新
    new webpack.HotModuleReplacementPlugin(),
  ]
})